﻿using System.ComponentModel;
using RaytracerLib;
using RaytracerLib.Cameras;

namespace Raytracer.PropertyGridDecorators
{
    public abstract class CameraProperties : OrientedElementProperties
    {
        private Camera m_camera;

        public CameraProperties(Camera a_camera) :
            base(a_camera)
        {
            m_camera = a_camera;
        }

        [TypeConverter(typeof(FilmConverter))]
        [Category(Categories.PROPERTIES)]
        public Film Film
        {
            get
            {
                return m_camera.Film;
            }
            set
            {
                if (value == null)
                    return;

                m_camera.Film = value;
            }
        }
    }

    public abstract class PlaneCameraProperties : CameraProperties
    {
        private PlaneCamera m_camera;

        public PlaneCameraProperties(PlaneCamera a_camera) :
            base(a_camera)
        {
            m_camera = a_camera;
        }

        [Category(Categories.PROPERTIES)]
        [TypeConverter(typeof(DoubleConverter))]
        public double FOV
        {
            get
            {
                return m_camera.FOV;
            }
            set
            {
                m_camera.FOV = value;
            }
        }

        [Category(Categories.PROPERTIES)]
        [TypeConverter(typeof(DoubleConverter))]
        public double MinimalPlaneDistant
        {
            get
            {
                return m_camera.MinimalPlaneDistant;
            }
            set
            {
                m_camera.MinimalPlaneDistant = value;
            }
        }
    }

    public class PerspectiveCameraProperties : PlaneCameraProperties
    {
        private Camera m_camera;

        public PerspectiveCameraProperties(PerspectiveCamera a_camera) :
            base(a_camera)
        {
            m_camera = a_camera;
        }
    }
}